package ip.demo.ip;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @Description:
 * @Author: liujinsheng
 * @Date: 2021/6/9.
 */
@RestController
public class IpTest {
    @GetMapping("/ip")
    public void getRemoteIp(HttpServletRequest request) {
        String remoteIp = request.getRemoteAddr();
        System.out.println("remoteIp" + remoteIp);
        String host = request.getRemoteHost();
        System.out.println("host" + host);
        GetHostIP getHostIP=new GetHostIP();
       String    ipp=  getHostIP.getHostIP();
        System.out.println("ipp"+ipp);
        String User = request.getRemoteUser();
        System.out.println("user" + User);
    }
}
